export const mixin = {
  methods: {
    // 提示信息
    notify(title, type) {
      this.$notify({
        title: title,
        type: type
      })
    },

    getUrl(pic) {
      return this.$store.state.HOST + pic;
    },

    attachBirth(val) {
      return String(val).substr(0, 10);
    },
    changeSex(sex) {
      if (sex == 1) {
        return '男';
      }
      return '女';
    },
    beforeAvatarUpload(file) {
      const isJPG = (file.type === 'image/jpeg') || (file.type === 'image/png');
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!');
      }
      return isJPG && isLt2M;
    },
    handleAvatarSuccess(res) {
      let _this = this;
      if (res.code == 1) {
        _this.$message.success("修改成功！");
        _this.getData();
      } else {
        _this.$message.error("修改失败！");
      }
    },
    beforeSongUpload(file) {
      let type=file.name.substring(file.name.lastIndexOf('.')+1);
      if(type!='mp3'){
        return false;
      }
      return true;
    },
    handleSongSuccess(res) {
      let _this = this;
      if (res.code == 1) {
        _this.$message.success("修改成功！");
        _this.getData();
      } else {
        _this.$message.error("修改失败！");
      }
    }

  }
}
